package entity

import (
	"gorm.io/gorm"
	"shqsoft.cn/pas3ui/base"
)

// NZJETZJE
type NZTZJE struct {
	NF       int     `gorm:"column:NF"`       //发放季度
	DPID     int     `gorm:"column:DPID"`     //部门id
	DPNM     string  `gorm:"column:DPNM"`     //部门
	EMNO     string  `gorm:"column:EMNO"`     //工号
	EMNM     string  `gorm:"column:EMNM"`     //姓名
	NZJX     float64 `gorm:"column:NZJX"`     //年终业绩绩效
	NZJXTZJE float64 `gorm:"column:NZJXTZJE"` //年终业绩绩效调整金额
	TZYY     string  `gorm:"column:TZYY"`     //调整原因
	TZJECW   string  `gorm:"column:TZJECW"`   //调整原因错误
	ISYYS    int     `gorm:"column:ISYYS"`    //营业室人员
	PDID     int     `gorm:"column:PDID"`     //部门id
	SFJE     float64 `gorm:"column:SFJE"`
}

// TableName
func (NZTZJE) TableName() string {
	return "SH_JHCW_JXFF_YGJX_NZ"
}

func (c *NZTZJE) AfterFind(tx *gorm.DB) (err error) {
	sqlStr := `select ROUND(sum("YJJX"/7*3),2)NZJX from "SH_JHCW_JXFF_YGJX_NZ"where "NF" = ? and "EMNO" = ? and "PDID" = ? `
	tx.Raw(sqlStr, c.NF, c.EMNO, c.PDID).Row().Scan(&c.NZJX)
	sqlStr = `select "NZJXTZJE" , "TZYY"  from "SH_JHCW_JXFF_YGJX_NZ_TZJE" where "NF" = ? and "PDID" = ? and "EMNO" = ?`
	tx.Raw(sqlStr, c.NF, c.PDID, c.EMNO).Row().Scan(&c.NZJXTZJE, &c.TZYY)
	return
}

// ShCompClieQygmEF 返回结构体
func NZTZJEEF() base.EntityFunc {
	return func() interface{} {
		entity := NZTZJE{}
		return &entity
	}
}

// ShCompClieQygmESF 返回结构体数组
func NZTZJEESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []NZTZJE
		return &entities
	}
}
func init() {
	base.DaoPoolObj.Put("NZTZJE", base.NewDefaultDao(NZTZJEEF(), NZTZJEESF(), nil, "my"))
}
